package com.google.code.esper.spring;

import com.espertech.esper.client.Configuration;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.core.io.Resource;

/**
 *
 */
public class EsperConfigurationFactoryBean extends AbstractFactoryBean<Configuration> {

    private Resource configuration;

    @Override
    public Class<? extends Configuration> getObjectType() {
        return Configuration.class;
    }

    @Override
    protected Configuration createInstance() throws Exception {
        Configuration instance = new Configuration();
        instance.configure(configuration.getURL());
        return instance;
    }

    public void setConfiguration(Resource configuration) {
        this.configuration = configuration;
    }
}
